//
//  JMStepView.m
//  NewiOSProject
//
//  Created by apple on 2023/11/29.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "JMAuthStepView.h"
@interface JMAuthStepView()
@property (nonatomic, strong)UIImageView *topImgV;
@property (nonatomic, strong)UILabel *pointV;
@property (nonatomic, strong)UILabel *priceLab;
@end
@implementation JMAuthStepView

-(instancetype)initWithFrame:(CGRect)frame steps:(NSArray *)steps step:(NSInteger)step{
    if (self = [super initWithFrame:frame]) {
        
        _topImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, kAppW(), NAVIGATION_BAR_HEIGHT()+154))];
        [_topImgV setImage:ImageNamed(@"auth_top")];
        [self addSubview:_topImgV];
        
        NSDictionary *item =steps[step-1];
        NSString *price = item[item.allKeys.firstObject];
        
        _priceLab = [JMControl createLabelWithFrame:(CGRectMake(0, NAVIGATION_BAR_HEIGHT()+24, kAppW(), 45)) Font:fontWithWeight(22, UIFontWeightMedium) Text:[NSString stringWithFormat:@"$%@",price] color:Hex_Str_COLOR(@"#ffffff")];
        _priceLab.textAlignment = 1;
        if ([price isEqualToString:@"?"]) {
            _priceLab.text = @"?";
        }
        _priceLab.textAlignment = 1;
        [self addSubview:_priceLab];
        
        for (int i=0; i<steps.count; i++) {
            CGFloat space =(kAppW()-48-24*7)/6.0;
            CGFloat left = 24+(24+space)*i;
            UILabel *stepLab = [JMControl createLabelWithFrame:(CGRectMake(left, _priceLab.bottom+30, 24, 24)) Font:BoldFont(18) Text:@(i+1).stringValue color:mainSchemeColor()];
            stepLab.textAlignment = 1;
            [self addSubview:stepLab];
            stepLab.cornerRadius = 12;
            if (i<=step-1) {
                stepLab.backgroundColor = WhiteColor();
                if (i==step-1) {
                    stepLab.layer.borderColor = HexAlpha_Str_COLOR(@"#ffffff", 0.4).CGColor;
                    stepLab.layer.borderWidth = 2;
                }
            }else{
                stepLab.backgroundColor = HexAlpha_Str_COLOR(@"#ffffff", 0.5);
            }
        }
    }
    return self;
}

@end
